package com.itheima.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: HelloController
 * @Description:
 * @author: Yrd
 * @date: 2021-11-25 21:48
 */
@RestController
@RequestMapping("/helloController")
public class HelloController {

    private static final Logger log= LoggerFactory.getLogger(HelloController.class);

    @RequestMapping("/hello")
    public String hello(){
        // 打印日志信息
        log.error("error");
        log.warn("warn");
        log.info("info");
        log.debug("debug");
        log.trace("trace");
        // 使用占位符输出日志信息
        String name = "jack";
        Integer age = 18;
        log.info("用户：{},{}", name, age);
        // 将系统异常信息写入日志
        try {
            @SuppressWarnings("unused")
            int i = 1 / 0;
        } catch (Exception e) {
            // e.printStackTrace();
            log.info("出现异常：", e);
        }
        return "hello Spring Boot!";
    }
}
